package com.cisdi.analysis.web.controller;

import com.cisdi.analysis.common.page.Page;
import com.cisdi.analysis.core.vo.ResultVO;
import com.cisdi.analysis.service.DataAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 分析数据控制器
 * @author liujunnan
 * @date 2018/5/23
 */
@RestController
@RequestMapping("/analysis-data")
public class DataAnalysisController {

    @Autowired
    private DataAnalysisService dataAnalysisService;

    /**
     * 求平均数，返回值为每一列的平均数
     * @return ResultVO
     */
    @GetMapping("/average")
    public ResultVO average() {
        return dataAnalysisService.average();
    }

    /**
     * 求方差
     * @return 每一列的方差
     */
    @GetMapping("/standard-deviation")
    public ResultVO standardDeviation() {
        return dataAnalysisService.standardDeviation();
    }

    /**
     * 求离群值
     * @return 每一列的离群值
     */
    @GetMapping("/outlier")
    public Map<Object, Integer> outlier() {
        return dataAnalysisService.outlier();
    }

    /**
     * 求因子数
     * @return 因子数
     */
    @GetMapping("/factor")
    public Integer factor() {
        return dataAnalysisService.factor();
    }

    @GetMapping("/data")
    public Page<ResultVO> getData(Integer pageNum, Integer pageSize) {
        return dataAnalysisService.getData(pageNum,pageSize);
    }
}
